# -*- coding: utf-8 -*-

import time, functools

def log(param=None):
  startTime = time.time()
  def returnFn(fn, text = 'call'):
    @functools.wraps(fn)
    def wrapper(*args, **kw):
      print('begin call')
      rec = fn(*args, **kw)
      print('%s %s(): return %s' % (text, fn.__name__, rec))
      print('end call and executed in %sms' % (time.time() - startTime))
      return rec
    return wrapper
  if isinstance(param, str):
    def decorator(func):
      returnFn(func, param)
    return decorator
  else:
    return returnFn(param)